﻿using System;
using System.Windows;
using System.Windows.Controls;
using External.Controls.ModelViews;
using External.Core;

namespace External.Controls.Controls
{
    public class SeatStateTemplateSelector : DataTemplateSelector
    {
        public DataTemplate NotInSale { get; set; }
        public DataTemplate Reserved { get; set; }
        public DataTemplate Sold { get; set; }
        public DataTemplate Agent { get; set; }
        public DataTemplate Sale { get; set; }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            var viewModel = (SeatViewModel) item;
            Seat seat = viewModel.Seat;

            switch (seat.State)
            {
                case SeatState.NotInSale:
                    return NotInSale;
                case SeatState.Reserved:
                    return Reserved;
                case SeatState.Sold:
                    return Sold;
                case SeatState.Agent:
                    return Agent;
                case SeatState.Sale:
                    return Sale;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
    }
}